//
//  DetailNetRequstHelper.m
//  BCProjectB
//
//  Created by lanou3g on 15/12/19.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "DetailNetRequstHelper.h"
#import "AFNetworking.h"
#import "BCReadDetailModel.h"
#import "Reachability.h"

@implementation DetailNetRequstHelper
-(void)requstReadListView:(void(^)(id objc))result with:(NSString *)str with:(NSString *)str1 and:(NSString *)str2{
    AFHTTPSessionManager *manger=[AFHTTPSessionManager manager];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"application/x-javascript", nil];
    NSDictionary *parameters=@{@"sort":str,@"start":str1,@"typeid":str2,@"client":@"2",@"C8Rm1F32zofhDC8lwEMHrlDJxQML5MOTcp2tvCjBjcWP22NdPTB9Y6P8":@"auth",@"limit":@"10"};
    [manger POST:@"http://api2.pianke.me/read/columns_detail" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSArray *array = responseObject[@"data"][@"list"];
        NSMutableArray *mutableArray = [NSMutableArray array];
        for (NSDictionary *dic in array) {
            BCReadDetailModel *model=[BCReadDetailModel new];
            [model setValuesForKeysWithDictionary:dic];
            [mutableArray addObject:model];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            result(mutableArray);
        });

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];

};
+(BOOL)checkNetIsConectOrNot{
    Reachability *reach=[Reachability reachabilityWithHostName:@"www.baidu.com"];
    if ([reach currentReachabilityStatus]==ReachableViaWiFi||[reach currentReachabilityStatus]==ReachableViaWWAN) {
        return YES;
    }
    return NO;
}


@end
